package com.itheima.spring.controller;

import com.itheima.spring.dao.AccountDao;
import com.itheima.spring.service.AccountService;
import com.itheima.spring.service.impl.AccountServiceImpl;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @Description：客户端
 */
public class ClientController {

    /**
     * ApplicationContext:spring-IOC容器
     * ClassPathXmlApplicationContext：容器实现类，加载配置文件
     * applicationContext.getBean：获得容器中的bean对象
     */
    @Test
    public void createAccount(){
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("bean.xml");
        AccountDao accountDao = (AccountDao) applicationContext.getBean("accountDao");
        AccountService accountService = (AccountService) applicationContext.getBean("accountService");
        accountService.setAccountDao(accountDao);
        accountService.createAccount();
    }
}